
#if	!defined( __20080806_DEF_CENV_LINUX32_GCC_H__ )
#define	__20080806_DEF_CENV_LINUX32_GCC_H__

#include	<assert.h>
#include	<string.h>
#include	<unistd.h>
#include    <stdio.h>

namespace PCE_Lib {
namespace CEnv_Def {

//////////////////////////////////////////////////////////////
// types
namespace Linux32_GCC
{
	typedef	signed char			int8_t;
	typedef	unsigned char		uint8_t;
	typedef	signed short		int16_t;
	typedef	unsigned short		uint16_t;
	typedef signed int			int32_t;
	typedef	unsigned int		uint32_t;
	typedef signed long long	int64_t;
	typedef unsigned long long	uint64_t;

	typedef	int32_t				ssize_t;
	typedef	size_t				usize_t;

	typedef	ssize_t				enum_t;
	typedef	char				char_t;
	typedef	float				float32_t;
	typedef	double				float64_t;

	#undef	Null
	template< typename T > T Null( void ) throw() { return static_cast< T >( 0 ); }
	template< typename T > bool IsNull( T p ) throw() { return Null< T >() == p; }
	template< typename T > bool NotNull( T p ) throw() { return ! IsNull( p ); }
	template< typename T > void SetNull( T & p ) throw() { p = Null< T >(); }

	template< typename T > void ObjectReference( const T & ) {}
}

/////////////////////////////////////////////////////////////
// string & memory functions

namespace Linux32_GCC
{
	inline usize_t pce_strlen( const char_t * str )
	{
		assert( NotNull( str ) );
		return strlen( str );
	}

	inline void * pce_memcpy( void * dest, const void * src, usize_t count )
	{
		assert( NotNull( dest ) );
		assert( NotNull( src ) );
		assert( count > 0 );
		return memcpy( dest, src, count );
	}

	inline char_t * pce_strcpy( char_t * dst, const char_t * src )
	{
		assert( NotNull( dst ) );
		assert( NotNull( src ) );
		return strcpy( dst, src );
	}
}

/////////////////////////////////////////////////////////////
// misc functions

namespace Linux32_GCC
{
	inline void pce_usleep( uint32_t usec )
	{
		assert( usec > 0 );
		usleep( usec * 1000 );
	}
}

/////////////////////////////////////////////////////////////
// file functions

namespace Linux32_GCC
{
    inline bool pce_remove( const char_t * filename )
    {
        assert( NotNull( filename ) );
        return 0 == remove( filename );
    }
}

}	// namespace CEnv_Def
}	// namespace PCE_Lib

#endif	// __20080806_DEF_CENV_LINUX32_GCC_H__
